
var results;
var curCulture;
var invarCulture;

function pageLoad() {
    results = $get('results');
    curCulture = Sys.CultureInfo.CurrentCulture;
    invarCulture = Sys.CultureInfo.InvariantCulture;
}

function clearResults() {
    results.innerHTML = '';
}

function writeResults(value) {
    results.innerHTML = value;
}

function appendResults(name, value) {
    var mask = '<b>{0} : </b>{1}<br />';
    results.innerHTML += String.format(mask, name, value);
}

function dumpTable(collection, maxDepth, currentDepth) {
    var sb = new Sys.StringBuilder();
    currentDepth++;
    var mask = '<tr><td>{0}</td><td>{1}</td></tr>';
    var content = new String();
    sb.append('<table border=1>');
    for (var item in collection) {
        if(currentDepth<maxDepth & typeof(collection[item]) == 'object') {
            content = dumpTable(collection[item], maxDepth, currentDepth);
        } else {
            content = collection[item];
        }
        if(content == '')
            content = '&nbsp;'
        sb.append(String.format(mask, item, content));
    }
    sb.append('</table>');
    return sb.toString();
}

function CurrentCulturename_onclick() {
    clearResults();
    appendResults('Culture Name', curCulture.name);
}

function CurrentCulturedateTimeFormat_onclick() {
    writeResults(dumpTable(curCulture.dateTimeFormat, 1, 0));
}

function CurrentCulturenumberFormat_onclick() {
    writeResults(dumpTable(curCulture.numberFormat,1, 0));
}

function InvariantCulturename_onclick() {
    clearResults();
    appendResults('Invariant Name', invarCulture.name);
}

function InvariantCulturedateTimeFormat_onclick() {
    writeResults(dumpTable(invarCulture.dateTimeFormat,10, 0));
}

function InvariantCulturenumberFormat_onclick() {
    writeResults(dumpTable(invarCulture.numberFormat,10, 0));
}
